package com.ian.offer;

import java.util.ArrayList;
import java.util.List;

/**
 * @author zhangyaowen
 * @date 2021/2/21 10:02 下午
 */
public class FindContinuousSequence {


    public int[][] findContinuousSequence(int target) {
        int i = 0;
        int j = 0;
        int sum = 0;
        List<int[]> list = new ArrayList<>();


        while(i< target>>1){
            if (sum<target){
                j++;
                sum +=j;
            }else if(sum> target){
                i++;
                sum -=i;
            }else{

                int[] arr = new int[j-i];
                for (int k = i; k < j; k++) {
                    arr[k-i] = i;
                }
                list.add(arr);

            }

        }

        return  list.toArray(new int[list.size()][]);
    }

}
